﻿package  {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class Ice extends MobObj {
		
		private var player:Player;
		
		public function Ice(aX:Number,aY:Number,aWidth:Number,aHeight:Number,p:Player) {
			super(aX,aY,aWidth,aHeight);
			player = p;
			
		}
		public override function Update(){
			VelX = 5*Math.cos(rotation*Math.PI/180) - player.VelX;
			VelY = 5*Math.sin(rotation*Math.PI/180) - player.VelY;
			super.Update();
			
		}
		
		protected override function CollisionX():Boolean
		{
			var go:Boolean = true;
			var nextX:int;
			nextX = x;
			nextX += VelX;
							
			if(VelX > 0){
				nextX += width;
			}
			
			for(var i:int = 0; i < player.tiles.length; i++){
					if(player.tiles[i].CollisionCheck(nextX, y) && this.stage)
					{
						parent.removeChild(this);
					}
					if(player.tiles[i].CollisionCheck(nextX, y + height) && this.stage)
					{
						parent.removeChild(this);
					}
			}
			return go;
			
		}
		
		
		
		protected override function CollisionY():Boolean
		{
			var go:Boolean = true;
			var nextY:int;
			
			nextY = y;
			nextY += VelY;
				
			if(VelY > 0){
				nextY += height;
			}
			for(var i:int = 0; i < player.tiles.length; i++){
					if(player.tiles[i].CollisionCheck(x, nextY) && this.stage)
					{
						parent.removeChild(this);
					}
					if(player.tiles[i].CollisionCheck(x + width, nextY) && this.stage)
					{
						parent.removeChild(this);
					}
			}
			return go;
		}
		
		
		
	}
	
}
